package base

import (
	"fmt"
	"math"
	"strings"
)

func Data() {
	var f32 = math.MaxFloat32
	var f64 = math.MaxFloat64

	fmt.Println(f32, f64)

	var c = 1 + 2i
	fmt.Printf("%T %v", c, c)
	fmt.Println(real(c) + imag(c))

	var s = "aaa"
	fmt.Println(len(s))

	fmt.Println(strings.Split(s, ""))

	s = "aa我是中国人"
	fmt.Println(s)

	fmt.Println(len(s))
	for i := 0; i < len(s); i++ { //按字节遍历
		fmt.Print(s[i])
		fmt.Print(" ")
	}
	fmt.Println()

	for _, value := range s { //按rune遍历
		fmt.Print(value)
		fmt.Print(" ")
	}
	fmt.Println()

	fmt.Println(s)         //string
	fmt.Println([]byte(s)) //[]byte
	fmt.Println([]rune(s)) //[]rune

	has := strings.HasPrefix(s, "aa")
	fmt.Println(has)

	index := strings.IndexByte(s, 'a')
	fmt.Println(index)

	index = strings.IndexRune(s, '中')
	fmt.Println(index)

	index = strings.Index(s, "中")
	fmt.Println(index)

	str := s[index:]
	fmt.Println(str)
	str = s[:index]
	fmt.Println(str)

	index = strings.LastIndex(s, "人")
	fmt.Println(index)

	var c1 = 'a'
	var c2 = '中'
	fmt.Printf("%T %T\n", c1, c2)

	fmt.Println(math.Sqrt(5 * 5))

}
